<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>结束循环</title>
</head>

<body>
  <script>
    let i = 1
    while (i < 5) {
      // 当吃到第三个的时候不吃了,用break结束循环
      if (i === 3) {
        break //结束循环
      }
      document.write(`我要吃${i}个包子` + '<br>')
      i++
    }
    document.write('<hr>')
    let ii = 1
    while (ii < 5) {
      if (ii == 3) {
        ii++   //如果这里不自增的话,就会一直3小于5就一直卡死
        continue  //跳过此次的循环,继续下面的循环
      }
      document.write(`我要吃${ii}个包子` + '<br>')
      ii++
    }
  </script>
</body>

</html>